import {UserModel} from "../Model/userModel.js"
export const addUserDao = async (user)=>{
    return await UserModel.insertOne(user);
}
export const findUserDao = async (username)=>{
    return await UserModel.findOne({username});
}
export const updateDao = async (username,userInfo)=>{
    return await UserModel.findOneAndUpdate(
      { username: username }, // 查询条件
      { $set: { ...userInfo} }, // 更新内容
      { new: true } // 选项：true 表示返回更新后的文档。这是 Mongoose 对 returnDocument 的封装
    );
}
export const findUserByIdDao = async(id)=>{
    return await UserModel.findById(id)
}